package stmo.comparable;

public class TestComparable {

    /**
     *  Comparable接口
     */


    public static void main(String[] args) {

        Student student = new Student();
        student.setUsername("张三");
        student.setAge(18);
        Student student1 = new Student();
        student1.setAge(17);
        student1.setUsername("李四");
        Comparable max = getMax(student, student1);
        System.out.println(max);
    }

    public static Comparable getMax(Comparable c1,Comparable c2) {
        int i = c1.compareTo(c2);

        if(i >= 0){
            return c1;
        }else {
            return c2;
        }
    }

}
